/**
 * 
 */
package com.easidea.tim.entity.finance;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springside.core.dao.extend.Undeletable;

import com.easidea.tim.entity.BaseEntity;
import com.easidea.tim.entity.customer.Customer;
import com.easidea.tim.entity.system.orgnization.Staff;


/**
 * 应收总额
 * @author Harrison
 *
 */
@Entity(name = "tim_finance_duefrom_summary")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Undeletable(status = "deleted")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "tim_finance_duefrom_summary")
public class DueFromSummary extends BaseEntity {

    /**
	 * 
	 */
	private static final long serialVersionUID = -2365183618112654509L;
	
	public final static Short PAY_CLEARED_NOT = 0; /* 未付清 */
    public final static Short PAY_CLEARED_YES = 1; /* 已付清 */

    private Double amount; /* 总金额 */
    private Double payed; /* 已付金额 */
    private Customer customer; /* 对应客户，类型应该是"Supplier.PARTY_TYPE_CUSTOMER" */
    private Staff sales; /* 对应销售人员 */
    private List<DueFrom> duefromList; /* 应收清单 */
    private Short cleared; /* 是否已付清 */

    /**
     * @return the amount
     */
    @Column(name = "amount")
    public Double getAmount() {
        return amount;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(Double amount) {
        this.amount = amount;
    }

    /**
     * @return the payed
     */
    @Column(name = "payed", columnDefinition = "double not null default 0")
    public Double getPayed() {
        return payed;
    }

    /**
     * @param payed the payed to set
     */
    public void setPayed(Double payed) {
        this.payed = payed;
    }

    /**
     * @return the customer
     */
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name = "customer_id", columnDefinition = "bigint not null")
    public Customer getCustomer() {
        return customer;
    }

    /**
     * @param customer the customer to set
     */
    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    /**
     * @return the sales
     */
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name = "sales_id", columnDefinition = "bigint not null")
    public Staff getSales() {
        return sales;
    }

    /**
     * @param sales the sales to set
     */
    public void setSales(Staff sales) {
        this.sales = sales;
    }

    /**
     * @return the getDuefromList
     */
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "dueFromSummary", cascade = CascadeType.ALL)
    public List<DueFrom> getDuefromList() {
        return duefromList;
    }

    /**
     * @param deliveryList the deliveryList to set
     */
    public void setDuefromList(List<DueFrom> duefromList) {
        this.duefromList = duefromList;
    }

    /**
     * @return the cleared
     */
    @Column(name = "cleared", columnDefinition = "smallint default 0")
    public Short getCleared() {
        return cleared;
    }

    /**
     * @param cleared the cleared to set
     */
    public void setCleared(Short cleared) {
        this.cleared = cleared;
    }
}